# 作者: 薛文寅仟
# 2025年01月03日23时18分47秒
# 5443912@qq.com

def list_set_slice():
    test_list = [1, 2, 3, 4, 5, 6]
    test_list[3:3] = ['x', 'y', 'z']  # 往列表中插入一个列表,元组和字符串因为是不可变类型不能这样做
    print(test_list)
    # +运算符
    print([1, 2, 3] + [4, 5, 6])
    print((1, 2, 3) + (4, 5, 6))
    print("我是" + "大帅哥")
    # *运算符
    print(["Hi"] * 4)
    print((1, 2, 3) * 4)
    print("360 " * 4)
    # in/not in运算符
    my_dict = {"清华": '1', "北大": '2', "大连理工大学": '3'}
    print("大连理工大学" in my_dict)  # 字典判断的是key
    print("浙江大学" not in my_dict)
    # < > <= >= ==运算符
    print((1, 2, 3) < (3, 1, 1))  # 只比较第一个元素


def list_compare():
    a = [1, 2, 3]
    b = [1, 2, 3]
    print(a == b)
    a[0] = 2
    print(a)
    print(b)
    print(a is b)  # is运算符是判断两个对象的地址是否一致的，一致是True


def use_method():
    """
    容器的一些方法
    :return:
    """
    a = (1, 2, 3)
    b = ('a', 'b', 'c')

    print(zip(a, b))  # 直接print(zip(a,b))会得到<zip object at 0x000002D8C1EAB780>
    z = zip(a, b)
    for i in z:
        print(i, end="")
    print()
    print(list(zip(a, b)))
    print(dict(zip(a, b)))
    print(dict(zip(b, a)))
    # 如何使用enumerate
    seasons = ['Spring', 'Summer', 'Fall', 'Winter']
    list2 = list(enumerate(seasons))
    print(list2)
    my_dict = dict(list2)
    print({v: k for k, v in my_dict.items()})


def traversal():
    """
    字典遍历寻值
    :return:
    """
    students = [{"name": "阿土", "age": 20, "gender": True, "height": 1.7, "weight": 75.0},
                {"name": "小美", "age": 19, "gender": False, "height": 1.6, "weight": 45.0}]
    find_name = "阿土"
    find_age = 20
    for str_dict in students:
        print(str_dict)
        if str_dict["name"] == find_name and str_dict["age"] == find_age:
            print("找到了")
            break
        else:
            print("没有找到")
    print("循环结束")


if __name__ == '__main__':
    # list_set_slice()
    # list_compare()
    use_method()
    # traversal()